<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      .chart1 {
        width: 800px;
        height: 400px;
        /* background: #aaa; */
      }

      .chart2 {
        width: 800px;
        height: 400px;
      }
    </style>
    <script src="https://cdn.bootcdn.net/ajax/libs/echarts/5.4.3/echarts.js"></script>
  </head>
  <body>
    <div id="main" class="chart1"></div>
    <div id="main2" class="chart2"></div>

    <script>
      // 基于准备好的dom，初始化echarts实例
      var myChart = echarts.init(document.getElementById('main'));

      // 指定图表的配置项和数据
      var option = {
        xAxis: {
          data: ['衬衫', '羊毛衫', '雪纺衫', '裤子', '高跟鞋', '袜子']
        },
        yAxis: {},
        series: [
          {
            name: '销量',
            type: 'bar',
            data: [5, 20, 36, 10, 10, 20]
          },
          {
            name: '销量2',
            type: 'line',
            data: [52, 20, 36, 10, 10, 20]
          }
        ],

        title: {
          text: 'ECharts 入门示例'
        },
        tooltip: {},
        legend: {
          data: ['销量', '销量2']
        },
        
      };

      // 使用刚指定的配置项和数据显示图表。
      myChart.setOption(option);
    </script>
    <script>
      // 初始化图表
      const chart2 = echarts.init(document.getElementById("main2"))
      // 定义配置
      const option2 = {
        xAxis: {
          data: ['A', 'B', 'C', 'D', 'E']
        },
        yAxis: {},
        series: [
          {
            name: '商品库存',
            type: 'bar',
            data: [12, 23, 20, 30, 10]
          },
          {
            name: '商品销量',
            type: 'line',
            data: [11, 33, 40, 20, 20]
          }
        ],
        tooltip: {
          trigger: 'axis'
        },
        title: {
          text: '商品相关'
        },
        legend: {
          
        }
      }
      // 给图表设置配置
      chart2.setOption(option2)
    </script>
  </body>
</html>
